package edu.hue.jk.controller;

import edu.hue.jk.Mapper.StudentDao;
import edu.hue.jk.entity.Student;
import edu.hue.jk.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

/**
 * (Student)表控制层
 *
 * @author makejava
 * @since 2022-03-16 15:46:59
 */
@Controller
@RequestMapping("user/student")
public class StudentController {
    @Autowired
    private StudentService studentService;

    //展示所有学生信息
    @RequestMapping("/list")
    public String list(Model model){
        return studentService.list(model);
    }

    //添加学生信息
    @RequestMapping("add_1")
    public String add(Model model,Student student){

        return studentService.add(model,student);
    }

    //跳转到添加学生信息界面
    @RequestMapping("add")
    public String add(){
        return "addstudent";
    }

    //删除相应学生信息
    @RequestMapping("delete")
    public String delete(Model model,String sid){
        return studentService.delete(model,sid);
    }
    //根据修改信息更新学生信息
    @RequestMapping("update")
    public String update(Student student,Model model){
        return studentService.update(student,model);
    }

    //将需要修改学生的信息展示在修改页
    @RequestMapping("update_1")
    public String update(String sid,Model model){
        return studentService.updates(sid,model);
    }

    //跳转主页面
    @RequestMapping("home")
    public String home(){
        return "home";
    }

    //跳转到查询宿舍信息的界面
    @RequestMapping("selectroom")
    public String selectroom(){
        return studentService.selectroom();
    }

    //根据学号查询学生信息

    @RequestMapping("query")
    public String query(){
        return "querystudent_1";
    }
    @RequestMapping("query_1")
    public String query_1(Model model,String sid){
        return studentService.query_1(model,sid);
    }
}